package com.iRomantic.controller.manager;

import java.util.UUID;

import com.iRomantic.common.BaseController;
import com.iRomantic.common.oss.OSSService;
import com.iRomantic.common.util.FileUtil;
import com.iRomantic.config.Constant;
import com.iRomantic.domain.entity.Invitation;
import com.jfinal.upload.UploadFile;

public class InvitationController extends BaseController {
	
	public void create() throws Exception{
		//处理上传文件
		UploadFile file = this.getFile();
		Invitation invitation = this.getModel(Invitation.class);
		String fileName = FileUtil.randomFileName(file.getFileName());
		//file.getFile().renameTo(new File(path,fileName));
		OSSService.getInstance().save(Constant.INVITATION_PICTURE+invitation.getStr("weddingId")+"/"+fileName, file.getFile());
		invitation.set("url", fileName);
		invitation.save();
		renderJson(invitation);
	}

}
